#ifndef QQTDATASTRUCTCONVERTER_H
#define QQTDATASTRUCTCONVERTER_H

#include <QObject>

#include <qqtdatastruct.h>
#include <qqthighgrade_global.h>
/**
 * @brief The QQtDataStructConverter class
 * 数据结构转换器
 *
 * A Struct - toDict - Json流式结构 -> ::
 *             |
 *           Dict1 [Converter 1]
 *           Dict2
 *             |
 * M Struct - fromDict - Json流式结构 <- ::
 *             |
 *           Dict1 [Converter 2]
 *           Dict2
 *             |
 * C Struct - toDict - Json流式结构 -> ::
 */
class QQTHIGHGRADESHARED_EXPORT QQtDataStructConverter : public QObject
{
    Q_OBJECT

public:
    explicit QQtDataStructConverter ( QObject* parent = 0 )
        : QObject ( parent ) {}
    virtual ~QQtDataStructConverter() {}

    //不必继承
    virtual void Translate ( QQtDataStruct& source, QQtDataStruct& target ) {
        //source packer
        //source, toDict()
        QQtOrderedDictionary dict1;
        source.toDict ( dict1 );

        //work flow
        QQtOrderedDictionary dict2;
        TranslateDictionary ( dict1, dict2 );

        //target parse
        //target, fromDict()
        target.fromDict ( dict2 );
    }

    //用户继承下去实现字典内部数据结构的转换
    virtual void TranslateDictionary ( QQtOrderedDictionary& source, QQtOrderedDictionary& target ) {
        //source -> target
        //
        //target["size"] = source["size"];
        //target["data"] = source["data"];
        //target["tKey"] = source["sKey"];
        //...
    }

protected:

private:

};

#endif // QQTDATASTRUCTCONVERTER_H

